package com.zksk.admin.mapper.product;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksk.mbg.admin.domain.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface ProductReleaseDao extends BaseMapper<ProductRelease> {

    @Select("")
    public CustomerProdReq selectCustomerId(Long id);

    @Select("select a.id from platform_customer_prod_req a where a.customer_id=#{id}")
    public CustomerProdReq selectCustomerProdReqId(Long id);

    @Select("select a.id from platform_org_product a where a.org_id=#{id}")
    public OrgProduct selectOrgProdReqId(Long id);

    @Select("select * from platform_rate a where a. id =(select a.rate_id from platform_r_rate_org_prod a ,platform_org_product b where b.id =a.org_prod_id  and b.enum_prod_id =#{arg0} and b.org_id =#{arg1}) and a .type = #{arg2}\n")
    public Rate selectOrgRate(Long productEnumId,Long ogrId,String projectType);

    @Select("select * from platform_rate a where a. id =(select a.rate_id from platform_r_rate_customer_req a ,platform_customer_prod_req b where b.id =a.customer_prod_req_id  and b.prod_enum_id =#{arg0} and b.customer_id=#{arg1}) and a .type = #{arg2}\n")
    public Rate selectCustomerRate(Long productEnumId,Long customerId, String projectType);


    //新增查询机构产品的费率
    public List<Rate> selectOrgRate(@Param("productEnumId") Long productEnumId,@Param("orgId") Long orgId);

    //新增查询客户产品的费率
    public List<Rate> selectCustomerRate(@Param("productEnumId") Long productEnumId, @Param("customerId") Long customerId);

    @Select("select * from platform_rate a where a.id in  (select  b.rate_id from platform_r_release_rate b  where b.release_id =#{id})")
    //查看详情查询客户费率
    public List<Rate>  getCustomerRate(@Param("id") Long id);

    //查询客户名称下拉集合
    @Select("select  customer_name,customer_id from platform_customer ")
    public List<Customer> selectCustomerList();

    //查询机构名称下拉列表集合
    @Select("select a.org_id,a.org_name,a.org_type from platform_org a where a.org_id in (select a.org_id from platform_org_product a where a.enum_prod_id = #{productEnumId})\n ")
    public List<Org> selectOrgNameList(@Param("productEnumId") Long productEnumId);

}
